package com.example.scanner.zxing.controller;

import com.example.scanner.zxing.isbn.ISBNScannerUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * 测试
 *
 * @author zwg
 * @date 2025/8/15 10:42
 */
@Slf4j
@RestController
@RequestMapping("/scanner/zxing/isbn")
public class IsbnController{



    //创建
    @PostMapping("/image/file")
    public String ocrImageFile(@RequestParam MultipartFile file) {

        try {
            log.info("contentType:{}",file.getContentType());
            BufferedImage image = ImageIO.read(file.getInputStream());
            return ISBNScannerUtil.scanISBN(image);
        }catch (IOException e){
            log.error("读取图像文件错误",e);
            return "读取图像文件错误";
        }
    }




}
